from PIL import Image
bob = Image.open('spongebob.jpeg')
bob
bob.show()
bob.size
(640, 399)
bob.format
'JPEG'
bob.mode
'RGB'
w, h = bob.size
w*h
255360
bob.convert('L')
bob.convert('1')
plankton = Image.open('plankton.jpg')
plankton
bob
crop_box = ( 180, 80, 500, 390 )
bob_face = bob.crop(crop_box)
bob_face.save('face.jpg')
bob.resize(( 320, 100 ))
small_img = bob.resize(( w//2, h//2 ))
small_img
small_img.resize((w*3, h*3))
plankton2 = Image.open('plankton2.jpg')
plankton2 = plankton2.resize((w, h))
Image.blend(bob, plankton2, 0.8)
bob.rotate(20)
bob.transpose(Image.ROTATE_90)
bob.transpose(Image.FLIP_LEFT_RIGHT)
bob.transpose(Image.FLIP_TOP_BOTTOM)
Image.blend(bob, bob.transpose(Image.FLIP_TOP_BOTTOM), 0.4)
from PIL import ImageFilter
bob.filter(ImageFilter.BLUR)
blurred = bob.filter(ImageFilter.BoxBlur(5))
blurred
bob.filter(ImageFilter.DETAIL)
bob.filter(ImageFilter.EMBOSS)
bob.filter(ImageFilter.FIND_EDGES)
bob.filter(ImageFilter.SHARPEN)
bob.filter(ImageFilter.CONTOUR)
ex_img = blurred
for i in range(5):
ex_img = ex_img.filter(ImageFilter.SHARPEN)
ex_img
bob.thumbnail((100, 100))
bob
import os
images_path = []
for f in os.listdir('C:\Summer Training\DP_PYDS_500\image_processing'):
if f.endswith('.jpg'):
images_path.append('C:\Summer Training\DP_PYDS_500\image_processing\\'+f)
images_path
['C:\\Summer Training\\DP_PYDS_500\\image_processing\\face.jpg', 'C:\\Summer Training\\DP_PYDS_500\\image_processing\\plankton.jpg', 'C:\\Summer Training\\DP_PYDS_500\\image_processing\\plankton2.jpg']
# WAP to create and save thumbnail of images in a given folder